<template>
  <div>
    <Header></Header>

    <div class="m-content" >

      <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">




<!--        <el-form-item label="内容" prop="content">-->


          <el-input
              type="textarea"
              :autosize="{ minRows: 2, maxRows: 10}"
              placeholder="请输入内容"
              v-model="ruleForm.content">
          </el-input>

<!--&lt;!&ndash;        </el-form-item>&ndash;&gt;-->
<!--        <el-upload-->
<!--            action="https://jsonplaceholder.typicode.com/posts/"-->
<!--            list-type="picture-card"-->
<!--            :on-preview="handlePictureCardPreview"-->
<!--            :on-remove="handleRemove"-->
<!--            v-model="ruleForm.picFile">-->
<!--          <i class="el-icon-plus"></i>-->
<!--        </el-upload>-->
<!--&lt;!&ndash;        <el-dialog :visible.sync="dialogVisible">&ndash;&gt;-->
<!--&lt;!&ndash;          <img width="100%" :src="dialogImageUrl" alt="">&ndash;&gt;-->
<!--&lt;!&ndash;        </el-dialog>&ndash;&gt;-->


        <el-form-item>
          <el-button type="primary" @click="submitForm('ruleForm')">立即发送</el-button>
          <el-button @click="resetForm('ruleForm')">重置</el-button>
        </el-form-item>
      </el-form>

    </div>



  </div>


</template>

<script>
export default {
  // dialogImageUrl: '',
  // dialogVisible: false,
  name: "SendWeibo",
  data()
  {

    return{

      ruleForm:{
        userid :this.$store.getters.getUser.id,
        username :this.$store.getters.getUser.username,

         // ip:'',
         // ipAddr:returnCitySN.cip,
         // ipId:returnCitySN.cid,
         // ipName:returnCitySN.cname

      },
      rules:
          {
            content:[
              { required: true, message: '请输入内容', trigger: 'blur' },
              { min:10,max: 140, message: '长度在10 到 140 个字符', trigger: 'blur'}
            ]
          }

    }
  },
  methods: {
    handleRemove(file, fileList) {
      console.log(file, fileList);
    },
    handlePictureCardPreview(file) {
      this.dialogImageUrl = file.url;
      this.dialogVisible = true;
    },
    submitForm(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {

          this.$axios.post('/sendWeibo', this.ruleForm).then(res => {


          })
        } else {
          console.log('error submit!!');
          return false;
        }
      })


    },

    resetForm(formName) {
      this.$refs[formName].resetFields();
    }
    ,
    created: function () {

      console.log(this.ruleForm)

    }
  }
}

</script>
<style scoped>

</style>